<div id="tracking-content" class='wrap-content'>
    <div id="tracking-left">
        <?php if ( $this->ships->count() > 0 ): ?>
        <?php foreach ($this->ships as $ship): ?>
            <div class="tracking-ship-wrapper">
                <div class="tracking-thumb">
                    <?php if ($ship['general_info']['ship_on_arrival']) : ?>
                        <img src="<?php echo UPLOAD_URL . $ship['general_info']['ship_on_arrival'] ?>" width="100%" height="100%">
                    <?php else: ?>
                        <img src="<?php echo $this->baseUrl() ?>/public/images/input_ship.jpg" width="100%" height="100%">
                    <?php endif; ?>
                </div>
                <div class="tracking-detail">
                    <h1><?php echo $ship['general_info']['ship_name'] ?></h1>
                    <p>Port: <?php echo $ship['port']['name'] ?></p>
                    <p>ATA: <?php Core_Util::renderDate($ship['general_info']['ata']) ?></p>
                    <p>ATS: <?php Core_Util::renderDate($ship['general_info']['ats']) ?></p>
                </div>
                <div class="tracking-button">
                    <input type="submit" class="button detail-button" value="View detail" />
                    <div class="sub-detail-menu">
                        <?php if ($ship['dunnage_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/detail/gid/<?php echo $ship['general_info']['id'] ?>/step/dunnage/id/<?php echo $ship['dunnage_operation_id'] ?>'>
                                <div>Dunnage Service</div>
                            </a>
                        <?php endif; ?>
                        <?php if ($ship['cargo_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/detail/step/cargo/id/<?php echo $ship['cargo_operation_id'] ?>'>
                                <div>Cargo Service</div>
                            </a>
                        <?php endif; ?>
                        <?php if ($ship['tally_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/detail/step/tally/id/<?php echo $ship['tally_operation_id'] ?>'>
                                <div>Tally Service</div>
                            </a>
                        <?php endif; ?>
                    </div>
                    <input type="submit" class="button update-button" value="Update" />
                    <div class='sub-update-menu'>
                        <a href='<?php echo $this->baseUrl() ?>/service/update/step/generalinfo/id/<?php echo $ship['id'] ?>/tid/<?php echo $ship['id'] ?>'>
                            <div>General Info</div>
                        </a>
                        <?php if ($ship['dunnage_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/update/step/dunnage/id/<?php echo $ship['dunnage_operation_id'] ?>/ref_no/<?php echo $ship['ref_no'] ?>/tid/<?php echo $ship['id'] ?>'>
                                <div>Dunnage Service</div>
                            </a>
                        <?php endif; ?>
                        <?php if ($ship['cargo_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/update/step/cargo/id/<?php echo $ship['cargo_operation_id'] ?>/ref_no/<?php echo $ship['ref_no'] ?>/tid/<?php echo $ship['id'] ?>'>
                                <div>Cargo Service</div>
                            </a>
                        <?php endif; ?>
                        <?php if ($ship['tally_operation_id']): ?>
                            <a href='<?php echo $this->baseUrl() ?>/service/update/step/tally/id/<?php echo $ship['tally_operation_id'] ?>/ref_no/<?php echo $ship['ref_no'] ?>/tid/<?php echo $ship['id'] ?>'>
                                <div>Tally Service</div>
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        <?php endforeach; ?>
        <center>
            <div class="paging">
                <?php echo $this->paginationControl($this->paginator, "Sliding", "/_partial/paginator.phtml") ?>
            </div>
        </center>
        <?php else: ?>
            There's not any ship
        <?php endif; ?>
    </div>
    <div class="tracking-right">
        <h1>REFINE SHIPS</h1>
        <form method='GET'>
            <div class="elements">
                <label for="ref_no">Ref No</label>
                <input type="text" class="refine" id="ref_no" name='ref_no' placeholder="Enter text..." value="<?php echo $this->filters['ref_no'] ?>"/>
            </div>            
            <div class="elements">
                <label for="shipname">Ship name</label>
                <input type="text" class="refine" id="ship_name" placeholder="Enter text..." name="ship_name" value="<?php echo $this->filters['ship_name'] ?>"/>
            </div>
            <div class="elements">
                <label for="portofcall">Port of call</label>
                <select name="port_of_call" id="ddlOne">
                    <option value='0'>-- Select Port -- </option>
                    <?php foreach ($this->ports as $port): ?>
                        <option value="<?php echo $port->id ?>" <?php echo $this->filters['port_of_call'] == $port->id ? "selected" : "" ?>><?php echo $port['name'] ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="elements">
                <label for="ata">ATA</label>
                <input type="text" class="refine datetime" id="ata" placeholder="dd/mm/yy" name='ata'
                       value='<?php echo !empty($this->filters['ata']) ? Core_Util::renderDate($this->filters['ata']) : ""?>'/>
            </div>
            <div class="elements">
                <label for="ats">ATS</label>
                <input type="text" class="refine datetime" id="ats" placeholder="dd/mm/yy" name='ats'
                       value='<?php echo !empty($this->filters['ats']) ? Core_Util::renderDate($this->filters['ats']) : ""?>'/>
            </div>
            <div class='elements'>
                <input type="submit" class="button" value="Search" style="margin-right:5%" />
            </div>
        </form>    
        <div style="clear: both;">&nbsp;</div>
    </div>
    <div style="clear: both;">&nbsp;</div>
</div>
<script src='<?php echo $this->baseUrl() ?>/public/js/tracking.js'></script>
<link rel='stylesheet' type='text/css' href='<?php echo $this->baseUrl() ?>/public/css/jquery-ui/jquery-ui-1.10.3.css'/>
<script src='<?php echo $this->baseUrl() ?>/public/js/jquery-ui-1.10.3.js'></script>
<script src='<?php echo $this->baseUrl() ?>/public/js/input.js'></script>